﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.DAL;
using System.Data.SqlClient;
using System.Data;

namespace EHTSaleManager.Code.BLL
{
    public class SlideShowProvider
    {

        public static void IUSlideShow(SileShow theSileShow, bool IsAdd)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_IUSlideShow";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", theSileShow.ID));
            command.Parameters.Add(new SqlParameter("@ImageSlide", theSileShow.ImageSlide));
            command.Parameters.Add(new SqlParameter("@Status", theSileShow.Status));            
            command.Parameters.Add(new SqlParameter("@IsAdd", IsAdd));

            DataProvider.ExecuteNoneQuery(command);
        }
        public static void DeleteSlideShow(Int32 ID)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_DeleteSlidebyID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", ID));

            DataProvider.ExecuteNoneQuery(command);
        }

        public static DataSet GetSlide()
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetSlideShow";
            command.CommandType = CommandType.StoredProcedure;

            return DataProvider.ExecuteDataSet(command);
        }

        public static SileShow GetSildeByID(Int32 ID)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetSlideByID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", ID));
            DataSet ds = DataProvider.ExecuteDataSet(command);
            SileShow theSlide = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                theSlide = new SileShow();                
                theSlide.ID = Int32.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                theSlide.ImageSlide = ds.Tables[0].Rows[0]["ImageSlide"].ToString();
            }

            return theSlide;
        }
    }
}